package com.rigsofrods.truckeditor.rig;

import java.text.Collator;
import java.util.Locale;
import java.util.Set;
import java.util.TreeSet;

import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;


public class TruckFile extends TreeModelSupport{
	private TreeNode root;
	private TruckModel truckModel;
	private Set<String> sections = new TreeSet<String>(Collator.getInstance(Locale.US));

	public TruckFile(TreeNode root) {
		this.root = root;
		//System.out.println("New TruckFile: "+root);
	}

	@Override
	public Object getRoot() {
		return root;
	}

	@Override
	public Object getChild(Object parent, int index) {
		return ((TreeNode)parent).getChildAt(index);
	}

	@Override
	public int getChildCount(Object parent) {
		int c = 0;
		try{
			c = ((TreeNode)parent).getChildCount();
		}catch(ClassCastException e){
			e.printStackTrace();
		}
		return c;
	}

	@Override
	public boolean isLeaf(Object node) {
		return ((TreeNode)node).isLeaf();
	}

	@Override
	public void valueForPathChanged(TreePath path, Object newValue) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public int getIndexOfChild(Object parent, Object child) {
		return ((TreeNode)parent).getIndex(((TreeNode)parent));
	}
}